// index.js
import {reqBannerList,reqArticle} from '../../api/index'
Page({
  data: {
    value: '',
    bannerImgList: [], // 轮播图
    articleList:[], // 文章列表
  },
  onLoad() {
    this.getBannerList();
    this.getArticle();
  },
  // 去搜索
  toSearch(){
    wx.navigateTo({url:'/pages/homeSearch/homeSearch'});
  },
  // 去心里测评
  toHeartTest(){
    wx.navigateTo({url:'/pages/homeHeartTest/homeHeartTest'});
  },
  // 去资讯预约
  toTalkReservation(){
    wx.navigateTo({url:'/pages/homeTalkReservation/homeTalkReservation'});
  },
  // 去心里答疑
  toHeartAnswer(){
    wx.navigateTo({url:'/pages/homeHeartAnswer/homeHeartAnswer'});
  },
  // 去心里知识
  toHeartKnowledge(){
    wx.navigateTo({url:'/pages/homeHeartKnowledge/homeHeartKnowledge'});
  },
  // 去FM
  toFM(){
    wx.navigateTo({url:'/pages/homeFM/homeFM'});
  },
  // 去公益中心
  toWelfareCenter(){
    wx.navigateTo({url:'/pages/homeWelfareCenter/homeWelfareCenter'});
  },
  // 请求回答
  toAskAnswer(){
    wx.navigateTo({url:'/pages/homeAskAnswer/homeAskAnswer'});
  },
  // 去文章详情
  toArticle(){
    wx.navigateTo({url:'/pages/homeArticle/homeArticle'});
  },
  
  // 获取文章数据
  async getArticle(){
    let result = await reqArticle();
    // console.log(result.data.list);
    let List = result.data.list;
    this.setData({
      articleList: List,
    })
  },
  // 获取轮播图 
  async getBannerList() {
    let result = await reqBannerList();
    let imgList = result.data.list;
    this.setData({
      bannerImgList: imgList,
    })
	},
	toDetail(e){
		let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/homeArtDetail/homeArtDetail?id=${id}`,
    })
	}
})